﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm13 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonInsert_Click(object sender, EventArgs e)
        {
            var name = this.dc.HospitalInfos.Where(a => a.hospitalname.Equals(this.hospitalname.Value)).ToList();
            if (name.Count > 0)
            {
                this.Labelkq.Text = "Hospital name already exists";
            }
            else
            {
                string hospitalname = this.hospitalname.Value;
                string phoneno = this.phoneno.Value;
                string location = this.location.Value;
                string url = this.url.Value;
                adhospital(hospitalname, phoneno, location, url);
            }
        }
        public void adhospital(string hospitalname, string phoneno, string location, string url)
        {
            HospitalInfo hosp = new HospitalInfo();
            hosp.hospitalname = hospitalname;
            hosp.phoneno = phoneno;
            hosp.location = location;
            hosp.url = url;
            this.dc.HospitalInfos.InsertOnSubmit(hosp);
            this.dc.SubmitChanges();
            this.Labelkq.Text = "Insert Successful";
        }
    }
}